home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / QuickDraw3D 1.6 SDK / Mac SampleCode Previous / Grab Bag Samples - Mac / Current QD3D Libs & Headers / Interfaces / QD3DDrawContext.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-05-18  |  14.3 KB  |  493 lines  |  [TEXT/MPS ]

  1. /******************************************************************************
  2.  **                                                                             **
  3.  **     Module:        QD3DDrawContext.h                                         **
  4.  **                                                                          **
  5.  **                                                                          **
  6.  **     Purpose:    Draw context class types and routines                        **
  7.  **                                                                          **
  8.  **                                                                          **
  9.  **                                                                          **
  10.  **     Copyright (C) 1993-1997 Apple Computer, Inc. All rights reserved.     **
  11.  **                                                                          **
  12.  **                                                                          **
  13.  *****************************************************************************/
  14. #ifndef QD3DDrawContext_h
  15. #define QD3DDrawContext_h
  16.  
  17. #include "QD3D.h"
  18.  
  19. #if defined(PRAGMA_ONCE) && PRAGMA_ONCE
  20.     #pragma once
  21. #endif  /*  PRAGMA_ONCE  */
  22.  
  23. #if defined(OS_MACINTOSH) && OS_MACINTOSH
  24.  
  25. #if defined(__xlc__) || defined(__XLC121__)
  26.     #pragma options enum=small
  27. #endif
  28.  
  29. #include <Quickdraw.h>
  30. #include <FixMath.h>
  31. #include <GXTypes.h>
  32.  
  33. #if defined(__xlc__) || defined(__XLC121__)
  34.     #pragma options enum=reset
  35.     #pragma options enum=int
  36.     #pragma options align=power
  37. #elif defined(__MWERKS__)
  38.     #pragma enumsalwaysint on
  39.     #pragma options align=native
  40. #elif defined(__MRC__) || defined(__SC__)
  41.     #if __option(pack_enums)
  42.         #define PRAGMA_ENUM_RESET_QD3DDRAWCON 1
  43.     #endif
  44.     #pragma options(!pack_enums)
  45.     #pragma options align=power
  46. #endif
  47.  
  48. #endif  /* OS_MACINTOSH */
  49.  
  50.  
  51. #if defined(WINDOW_SYSTEM_X11) && WINDOW_SYSTEM_X11
  52.     #include <X11/Xlib.h>
  53.     #include <X11/Xutil.h>
  54. #endif /* WINDOW_SYSTEM_X11 */
  55.  
  56. #if defined(WINDOW_SYSTEM_WIN32) && WINDOW_SYSTEM_WIN32
  57.     #include <windows.h>
  58. /******************************************************************************
  59.  *                                                                             **
  60.  * ABOUT   QD3D_NO_DIRECTDRAW:     (Win32 Only)                                 **
  61.  *                                                                             **
  62.  * NOTE: Define QD3D_NO_DIRECTDRAW for your application makefile/project     **
  63.  *       only if you don't need Q3DDSurfaceDrawContext support and don't     **
  64.  *       have access to ddraw.h.                                             ** 
  65.  *                                                                             **
  66.  *****************************************************************************/
  67. #if !defined(QD3D_NO_DIRECTDRAW)
  68.     #include <ddraw.h>
  69. #endif /* !QD3D_NO_DIRECTDRAW */
  70. #endif  /*  WINDOW_SYSTEM_WIN32  */
  71.  
  72. #ifdef __cplusplus
  73. extern "C" {
  74. #endif /*  __cplusplus  */
  75.  
  76.  
  77. /******************************************************************************
  78.  **                                                                             **
  79.  **                            DrawContext Data Structures                         **
  80.  **                                                                             **
  81.  *****************************************************************************/
  82.  
  83. typedef enum TQ3DrawContextClearImageMethod{
  84.     kQ3ClearMethodNone,
  85.     kQ3ClearMethodWithColor
  86. } TQ3DrawContextClearImageMethod;
  87.  
  88.  
  89. typedef struct TQ3DrawContextData {
  90.     TQ3DrawContextClearImageMethod    clearImageMethod;
  91.     TQ3ColorARGB                    clearImageColor;
  92.     TQ3Area                            pane;
  93.     TQ3Boolean                        paneState;
  94.     TQ3Bitmap                        mask;
  95.     TQ3Boolean                        maskState;
  96.     TQ3Boolean                        doubleBufferState;
  97. } TQ3DrawContextData;
  98.  
  99.  
  100. /******************************************************************************
  101.  **                                                                             **
  102.  **                                DrawContext Routines                         **
  103.  **                                                                             **
  104.  *****************************************************************************/
  105.  
  106. QD3D_EXPORT TQ3ObjectType QD3D_CALL Q3DrawContext_GetType(
  107.     TQ3DrawContextObject        drawContext);
  108.  
  109. QD3D_EXPORT TQ3Status QD3D_CALL Q3DrawContext_SetData(
  110.     TQ3DrawContextObject        context,
  111.     const TQ3DrawContextData    *contextData);
  112.  
  113. QD3D_EXPORT TQ3Status QD3D_CALL Q3DrawContext_GetData(
  114.     TQ3DrawContextObject        context,
  115.     TQ3DrawContextData            *contextData);
  116.     
  117. QD3D_EXPORT TQ3Status QD3D_CALL Q3DrawContext_SetClearImageColor(
  118.     TQ3DrawContextObject        context,
  119.     const TQ3ColorARGB             *color);
  120.  
  121. QD3D_EXPORT TQ3Status QD3D_CALL Q3DrawContext_GetClearImageColor(
  122.     TQ3DrawContextObject        context,
  123.     TQ3ColorARGB                 *color);
  124.  
  125. QD3D_EXPORT TQ3Status QD3D_CALL Q3DrawContext_SetPane(
  126.     TQ3DrawContextObject        context,
  127.     const TQ3Area                 *pane);
  128.  
  129. QD3D_EXPORT TQ3Status QD3D_CALL Q3DrawContext_GetPane(
  130.     TQ3DrawContextObject        context,
  131.     TQ3Area                         *pane);
  132.  
  133. QD3D_EXPORT TQ3Status QD3D_CALL Q3DrawContext_SetPaneState(
  134.     TQ3DrawContextObject        context,
  135.     TQ3Boolean                    state);
  136.  
  137. QD3D_EXPORT TQ3Status QD3D_CALL Q3DrawContext_GetPaneState(
  138.     TQ3DrawContextObject        context,
  139.     TQ3Boolean                    *state);
  140.         
  141. QD3D_EXPORT TQ3Status QD3D_CALL Q3DrawContext_SetClearImageMethod(
  142.     TQ3DrawContextObject            context,
  143.     TQ3DrawContextClearImageMethod     method);
  144.         
  145. QD3D_EXPORT TQ3Status QD3D_CALL Q3DrawContext_GetClearImageMethod(
  146.     TQ3DrawContextObject            context,
  147.     TQ3DrawContextClearImageMethod     *method);
  148.         
  149. QD3D_EXPORT TQ3Status QD3D_CALL Q3DrawContext_SetMask(
  150.     TQ3DrawContextObject        context,
  151.     const TQ3Bitmap                *mask);
  152.         
  153. QD3D_EXPORT TQ3Status QD3D_CALL Q3DrawContext_GetMask(
  154.     TQ3DrawContextObject        context,
  155.     TQ3Bitmap                    *mask);
  156.  
  157. QD3D_EXPORT TQ3Status QD3D_CALL Q3DrawContext_SetMaskState(
  158.     TQ3DrawContextObject        context,
  159.     TQ3Boolean                    state);
  160.  
  161. QD3D_EXPORT TQ3Status QD3D_CALL Q3DrawContext_GetMaskState(
  162.     TQ3DrawContextObject        context,
  163.     TQ3Boolean                    *state);
  164.  
  165. QD3D_EXPORT TQ3Status QD3D_CALL Q3DrawContext_SetDoubleBufferState(
  166.     TQ3DrawContextObject        context,
  167.     TQ3Boolean                     state);
  168.  
  169. QD3D_EXPORT TQ3Status QD3D_CALL Q3DrawContext_GetDoubleBufferState(
  170.     TQ3DrawContextObject        context,
  171.     TQ3Boolean                     *state);
  172.  
  173.  
  174. /******************************************************************************
  175.  **                                                                             **
  176.  **                            Pixmap Data Structure                             **
  177.  **                                                                             **
  178.  *****************************************************************************/
  179.  
  180. typedef struct TQ3PixmapDrawContextData {
  181.     TQ3DrawContextData        drawContextData;
  182.     TQ3Pixmap                pixmap;
  183. } TQ3PixmapDrawContextData;
  184.  
  185.  
  186. /******************************************************************************
  187.  **                                                                             **
  188.  **                        Pixmap DrawContext Routines                             **
  189.  **                                                                             **
  190.  *****************************************************************************/
  191.  
  192. QD3D_EXPORT TQ3DrawContextObject QD3D_CALL Q3PixmapDrawContext_New(
  193.     const TQ3PixmapDrawContextData    *contextData);
  194.  
  195. QD3D_EXPORT TQ3Status QD3D_CALL Q3PixmapDrawContext_SetPixmap(
  196.     TQ3DrawContextObject            drawContext,
  197.     const TQ3Pixmap                    *pixmap);
  198.  
  199. QD3D_EXPORT TQ3Status QD3D_CALL Q3PixmapDrawContext_GetPixmap(
  200.     TQ3DrawContextObject            drawContext,
  201.     TQ3Pixmap                        *pixmap);
  202.  
  203. #if defined(WINDOW_SYSTEM_MACINTOSH) && WINDOW_SYSTEM_MACINTOSH
  204.  
  205. /******************************************************************************
  206.  **                                                                             **
  207.  **                        Macintosh DrawContext Data Structures                 **
  208.  **                                                                             **
  209.  *****************************************************************************/
  210.  
  211. typedef enum TQ3MacDrawContext2DLibrary {
  212.     kQ3Mac2DLibraryNone,
  213.     kQ3Mac2DLibraryQuickDraw,
  214.     kQ3Mac2DLibraryQuickDrawGX
  215. } TQ3MacDrawContext2DLibrary;
  216.  
  217.  
  218. typedef struct TQ3MacDrawContextData {
  219.     TQ3DrawContextData            drawContextData;
  220.     CWindowPtr                    window;
  221.     TQ3MacDrawContext2DLibrary    library;
  222.     gxViewPort                    viewPort;
  223.     CGrafPtr                    grafPort;
  224. } TQ3MacDrawContextData;
  225.  
  226.  
  227. /******************************************************************************
  228.  **                                                                             **
  229.  **                        Macintosh DrawContext Routines                         **
  230.  **                                                                             **
  231.  *****************************************************************************/
  232.  
  233. QD3D_EXPORT TQ3DrawContextObject QD3D_CALL Q3MacDrawContext_New(
  234.     const TQ3MacDrawContextData    *drawContextData);
  235.     
  236. QD3D_EXPORT TQ3Status QD3D_CALL Q3MacDrawContext_SetWindow(
  237.     TQ3DrawContextObject        drawContext,
  238.     const CWindowPtr            window);
  239.  
  240. QD3D_EXPORT TQ3Status QD3D_CALL Q3MacDrawContext_GetWindow(
  241.     TQ3DrawContextObject        drawContext,
  242.     CWindowPtr                    *window);
  243.  
  244. QD3D_EXPORT TQ3Status QD3D_CALL Q3MacDrawContext_SetGXViewPort(
  245.     TQ3DrawContextObject        drawContext,
  246.     const gxViewPort            viewPort);
  247.  
  248. QD3D_EXPORT TQ3Status QD3D_CALL Q3MacDrawContext_GetGXViewPort(
  249.     TQ3DrawContextObject        drawContext,
  250.     gxViewPort                    *viewPort);
  251.  
  252. QD3D_EXPORT TQ3Status QD3D_CALL Q3MacDrawContext_SetGrafPort(
  253.     TQ3DrawContextObject        drawContext,
  254.     const CGrafPtr                grafPort);
  255.  
  256. QD3D_EXPORT TQ3Status QD3D_CALL Q3MacDrawContext_GetGrafPort(
  257.     TQ3DrawContextObject        drawContext,
  258.     CGrafPtr                    *grafPort);
  259.  
  260. QD3D_EXPORT TQ3Status QD3D_CALL Q3MacDrawContext_Set2DLibrary(
  261.     TQ3DrawContextObject        drawContext,
  262.     TQ3MacDrawContext2DLibrary    library);
  263.  
  264. QD3D_EXPORT TQ3Status QD3D_CALL Q3MacDrawContext_Get2DLibrary(
  265.     TQ3DrawContextObject        drawContext,
  266.     TQ3MacDrawContext2DLibrary    *library);
  267.  
  268. #endif /* WINDOW_SYSTEM_MACINTOSH */
  269.  
  270. #if defined(WINDOW_SYSTEM_X11) && WINDOW_SYSTEM_X11
  271.  
  272. /******************************************************************************
  273.  **                                                                             **
  274.  **                                Types                                         **
  275.  **                                                                             **
  276.  *****************************************************************************/
  277.  
  278. typedef struct TQ3XBufferData *TQ3XBufferObject;
  279.  
  280. typedef struct TQ3XColormapData {
  281.     long        baseEntry;
  282.     long        maxRed;
  283.     long        maxGreen;
  284.     long        maxBlue;
  285.     long        multRed;
  286.     long        multGreen;
  287.     long        multBlue;
  288. } TQ3XColormapData;
  289.  
  290.  
  291. typedef struct TQ3XDrawContextData {
  292.     TQ3DrawContextData        contextData;
  293.     Display                    *display;
  294.     Drawable                drawable;
  295.     Visual                    *visual;
  296.     Colormap                cmap;
  297.     TQ3XColormapData        *colorMapData;
  298. } TQ3XDrawContextData;
  299.  
  300.  
  301. /******************************************************************************
  302.  **                                                                             **
  303.  **                            XDrawContext Routines                             **
  304.  **                                                                             **
  305.  *****************************************************************************/
  306.  
  307. #ifdef XDC_OLD
  308. QD3D_EXPORT TQ3DrawContextObject QD3D_CALL Q3XDrawContext_New(
  309.     void);
  310.  
  311. QD3D_EXPORT void QD3D_CALL Q3XDrawContext_Set(
  312.     TQ3DrawContextObject    drawContext,
  313.     unsigned long            flag,                             
  314.     void                    *data);
  315.  
  316. QD3D_EXPORT void QD3D_CALL Q3XDrawContext_Get(
  317.     TQ3DrawContextObject    drawContext,
  318.     unsigned long            flag,                             
  319.     void                    *data);
  320. #endif  /* XDC_OLD */
  321.  
  322. QD3D_EXPORT TQ3XBufferObject QD3D_CALL Q3XBuffers_New(
  323.     Display                    *dpy,                       
  324.     unsigned long            numBuffers,
  325.     Window                    window);
  326.  
  327. QD3D_EXPORT void QD3D_CALL Q3XBuffers_Swap(
  328.     Display                    *dpy,
  329.     TQ3XBufferObject        buffers);
  330.  
  331. QD3D_EXPORT XVisualInfo *QD3D_CALL Q3X_GetVisualInfo(
  332.     Display                    *dpy,
  333.     Screen                    *screen);
  334.  
  335.  
  336. QD3D_EXPORT TQ3DrawContextObject QD3D_CALL Q3XDrawContext_New(
  337.     const TQ3XDrawContextData    *xContextData);
  338.  
  339. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawContext_SetDisplay(
  340.     TQ3DrawContextObject        drawContext,
  341.     const Display                *display);
  342.  
  343. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawContext_GetDisplay(
  344.     TQ3DrawContextObject        drawContext,
  345.     Display                        **display);
  346.  
  347. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawContext_SetDrawable(
  348.     TQ3DrawContextObject        drawContext,
  349.     Drawable                    drawable);
  350.  
  351. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawContext_GetDrawable(
  352.     TQ3DrawContextObject        drawContext,
  353.     Drawable                    *drawable);
  354.  
  355. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawContext_SetVisual(
  356.     TQ3DrawContextObject        drawContext,
  357.     const Visual                *visual);
  358.  
  359. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawContext_GetVisual(
  360.     TQ3DrawContextObject        drawContext,
  361.     Visual                        **visual);
  362.  
  363. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawContext_SetColormap(
  364.     TQ3DrawContextObject        drawContext,
  365.     Colormap                    colormap);
  366.  
  367. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawContext_GetColormap(
  368.     TQ3DrawContextObject        drawContext,
  369.     Colormap                    *colormap);
  370.  
  371. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawContext_SetColormapData(
  372.     TQ3DrawContextObject        drawContext,
  373.     const TQ3XColormapData        *colormapData);
  374.  
  375. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawContext_GetColormapData(
  376.     TQ3DrawContextObject        drawContext,
  377.     TQ3XColormapData            *colormapData);
  378.  
  379. #endif /* WINDOW_SYSTEM_X11 */
  380.  
  381. #if defined(WINDOW_SYSTEM_WIN32) && WINDOW_SYSTEM_WIN32
  382.  
  383. /******************************************************************************
  384.  **                                                                             **
  385.  **                                Types                                         **
  386.  **                                                                             **
  387.  *****************************************************************************/
  388.  
  389. typedef struct TQ3Win32DCDrawContextData {
  390.     TQ3DrawContextData        drawContextData;
  391.     HDC                        hdc;
  392. } TQ3Win32DCDrawContextData;
  393.  
  394. #if !defined(QD3D_NO_DIRECTDRAW)
  395.  
  396. typedef enum {
  397.     kQ3DirectDrawObject        = 1,
  398.     kQ3DirectDrawObject2    = 2
  399. } TQ3DirectDrawObjectSelector;
  400.  
  401. typedef enum {
  402.     kQ3DirectDrawSurface    = 1,
  403.     kQ3DirectDrawSurface2    = 2
  404. } TQ3DirectDrawSurfaceSelector;
  405.  
  406. typedef struct TQ3DDSurfaceDescriptor {
  407.     TQ3DirectDrawObjectSelector        objectSelector;
  408.     union
  409.     {
  410.         LPDIRECTDRAW                lpDirectDraw;
  411.         LPDIRECTDRAW2                lpDirectDraw2;
  412.     };
  413.  
  414.     TQ3DirectDrawSurfaceSelector    surfaceSelector;
  415.     union
  416.     {
  417.         LPDIRECTDRAWSURFACE            lpDirectDrawSurface;
  418.         LPDIRECTDRAWSURFACE2        lpDirectDrawSurface2;
  419.     };
  420. } TQ3DDSurfaceDescriptor;
  421.  
  422. typedef struct TQ3DDSurfaceDrawContextData {
  423.     TQ3DrawContextData                drawContextData;
  424.     TQ3DDSurfaceDescriptor            ddSurfaceDescriptor;
  425. } TQ3DDSurfaceDrawContextData;
  426.  
  427. #endif /* !QD3D_NO_DIRECTDRAW */
  428.  
  429. /******************************************************************************
  430.  **                                                                             **
  431.  **                            Win32DC DrawContext Routines                     **
  432.  **                                                                             **
  433.  *****************************************************************************/
  434.  
  435. QD3D_EXPORT TQ3DrawContextObject QD3D_CALL Q3Win32DCDrawContext_New(
  436.     const TQ3Win32DCDrawContextData    *drawContextData);
  437.  
  438. QD3D_EXPORT TQ3Status QD3D_CALL Q3Win32DCDrawContext_SetDC(
  439.     TQ3DrawContextObject        drawContext,
  440.     const HDC                    hdc);
  441.  
  442. QD3D_EXPORT TQ3Status QD3D_CALL Q3Win32DCDrawContext_GetDC(
  443.     TQ3DrawContextObject        drawContext,
  444.     HDC                            *hdc);
  445.  
  446.  
  447. /******************************************************************************
  448.  **                                                                             **
  449.  **                            DDSurface DrawContext Routines                     **
  450.  **                                                                             **
  451.  *****************************************************************************/
  452. #if !defined(QD3D_NO_DIRECTDRAW)
  453.  
  454. QD3D_EXPORT TQ3DrawContextObject QD3D_CALL Q3DDSurfaceDrawContext_New(
  455.     const TQ3DDSurfaceDrawContextData    *drawContextData);
  456.  
  457. QD3D_EXPORT TQ3Status QD3D_CALL Q3DDSurfaceDrawContext_SetDirectDrawSurface(
  458.     TQ3DrawContextObject            drawContext,
  459.     const TQ3DDSurfaceDescriptor    *ddSurfaceDescriptor);
  460.  
  461. QD3D_EXPORT TQ3Status QD3D_CALL Q3DDSurfaceDrawContext_GetDirectDrawSurface(
  462.     TQ3DrawContextObject        drawContext,
  463.     TQ3DDSurfaceDescriptor        *ddSurfaceDescriptor);
  464.  
  465. #endif /* !QD3D_NO_DIRECTDRAW */
  466.  
  467. #endif  /*  WINDOW_SYSTEM_WIN32  */
  468.  
  469.  
  470. #ifdef __cplusplus
  471. }
  472. #endif /*  __cplusplus  */
  473.  
  474. #if defined(OS_MACINTOSH) && OS_MACINTOSH
  475.  
  476. #if defined(__xlc__) || defined(__XLC121__)
  477.     #pragma options enum=reset
  478.     #pragma options align=reset
  479. #elif defined(__MWERKS__)
  480.     #pragma enumsalwaysint reset
  481.     #pragma options align=reset
  482. #elif defined(__MRC__) || defined(__SC__)
  483.     #if PRAGMA_ENUM_RESET_QD3DDRAWCON
  484.         #pragma options(pack_enums)
  485.         #undef PRAGMA_ENUM_RESET_QD3DDRAWCON
  486.     #endif
  487.     #pragma options align=reset
  488. #endif
  489.  
  490. #endif  /* OS_MACINTOSH */
  491.  
  492. #endif  /*  QD3DDrawContext_h  */
  493.